****FIGURE 8****

cd "$main_dir/output/figures/main"

graph set window fontface "Palatino"

//--------------------------------------------------------
//Read in relevant datasets
//--------------------------------------------------------

clear
use "$data_dir/clean/harmonized_pooled_averages.dta"

merge 1:1 ccode using "$data_dir/raw/average_institutions.dta"
drop if _merge==2
drop _merge

merge 1:m ccode using "$data_dir/raw/mpd2023_clean.dta"
drop if _merge==2
drop _merge

sort ccode year

//--------------------------------------------------------
//Create Figure 8
//--------------------------------------------------------

scatter trust_govt_wo avg_10yr_exec if year==2008, mlabel(ccode) msize(vsmall) mlabsize(vsmall) mlabcolor(black) legend(off) || lfit trust_govt_wo avg_10yr_exec if year==2008, lcolor(maroon) graphregion(color(white)) bgcolor(white) ylabel(,labs(small) format(%9.2f)) xlabel(,labs(small)) xtitle("Executive Constraints", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small)) 
graph export "figure_8a.png", replace
graph export "figure_8a.tif", replace as(tif) width(3600)

scatter trust_govt_wo ln_gdppc if year==2019, mlabel(ccode) msize(vsmall) mlabsize(vsmall) mlabcolor(black) legend(off) || lfit trust_govt_wo ln_gdppc if year==2019, lcolor(maroon) graphregion(color(white)) bgcolor(white) ylabel(,labs(small) format(%9.2f)) xlabel(,labs(small)) xtitle("Log(GDP per capita)", margin(small) size(small)) ytitle("Trust in Government", margin(small) size(small))
graph export "figure_8b.png", replace
graph export "figure_8b.tif", replace as(tif) width(3600)
